package httpserver

import (
	"fmt"
	"go-http-server/app/httpserver/api"
	"net/http"

	"go-http-server/app/httpserver/home"
)

func Router() *http.ServeMux {
	home.InitWWWRoot()
	mux := http.NewServeMux()
	mux.Handle("/", http.HandlerFunc(home.Index))

	// mux.Handle("/api/", http.HandlerFunc(api.Index))
	fmt.Println("API列表: ")
	apiPrefix := "/api"
	for path, handle := range api.ApiCollector {
		fmt.Println(apiPrefix + path)
		mux.Handle(apiPrefix + path, http.HandlerFunc(handle))
	}

	return mux
}
